$(document).ready(function() {
	$("#modifyAnnounceForm").validate({
		onkeyup: false,
		onfocusout: false,
		rules: {
			title: {
				required: true,
				maxlength: 35
			},
			content: {
				required: true,
				maxlength: 200
			}
		},
		messages: {
			title: {
				required: "<br />*請輸入標題",
				maxlength: "<br />*標題不能超過35個字"
			},
			content: {
				required: "<br />*請輸入內容",
				maxlength: "<br />*內容不能超過200個字"
			}
		},
		errorPlacement: function(error, element) {
			error.css("color", "red");
			error.css("font-weight", "bold");
			error.insertAfter(element);
		},
		submitHandler: function(form) {
			var content = $("#modifyAnnounceContent").val();
			
			$("#modifyAnnounceSubmit").attr("disabled", "true");
			$("#modifyAnnounceContent").val(content.replace(/\n/g, "<br />"));
			$(form).ajaxSubmit();
			alert("修改成功");
			$(location).attr("href", "./editAnnounce");
		}
	});
});